package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import com.itheima.reggie.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//订单模块
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    //用户下单
    @PostMapping("/order/submit")
    public ResultInfo submit (@RequestBody Order order){
        orderService.submit(order);
        return ResultInfo.success();
    }

    //h5订单查询
    @GetMapping("/order/userPage")
    public ResultInfo findByUserPage(@RequestParam(value = "page",defaultValue = "1")Integer pageNum,
                                 @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
                                 String number){
        Page<Order> orderPage = orderService.findByUserPage(pageNum,pageSize,number);
        return ResultInfo.success(orderPage);

    }

}
